import {defineStore} from "pinia"
import {getBookContent} from "@/api/book";

export const bookContentStore = defineStore("bookContent", {
    state: () => {
        return {
            currentInfo: {},
            nextInfo: {},
            bookIndices: [],
            preInfo:{}
        }
    },
    actions: {
        async currentContent(chapterId) {
            const {data} = await getBookContent(chapterId);
            this.currentInfo = data
        },
        async nextContent(chapterId) {
            const {data} = await getBookContent(chapterId);
            this.nextInfo = data
        },
        async preContent(chapterId) {
            const {data} = await getBookContent(chapterId);
            this.preInfo = data
        }
    },
    getters: {
        current: (state) => state.currentInfo,
        next: (state) => state.nextInfo,
        chapterIncices: (state) => state.bookIndices,
        pre: state => state.preINfo
    }
})
